<?php

class Exam_Plugin_Menus
{
  public function canCreateExams()
  {
    // Must be logged in
    $viewer = Engine_Api::_()->user()->getViewer();
    if( !$viewer || !$viewer->getIdentity() ) {
      return false;
    }

    // Must be able to create exams
    if( !Engine_Api::_()->authorization()->isAllowed('exam', $viewer, 'create') ) {
      return false;
    }

    return true;
  }

  public function canViewExams()
  {
    $viewer = Engine_Api::_()->user()->getViewer();
    
    // Must be able to view exams
    if( !Engine_Api::_()->authorization()->isAllowed('exam', $viewer, 'view') ) {
      return false;
    }

    return true;
  }
  
  public function canViewMyTests(){
    $viewer = Engine_Api::_()->user()->getViewer();
    if(!$viewer || !$viewer->getIdentity()) return false;
    return true;
  }
}